/*
This file is part of AI Agent Feed.

"AI Agent Feed" is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

"AI Agent Feed" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with "AI Agent Feed".  If not, see <http://www.gnu.org/licenses/>.
 */
package com.feed.domain;

import java.io.Serializable;


public class FeedProvider implements Comparable<FeedProvider>, Serializable  {

	private static final long serialVersionUID = 1L;

	public static final int INDEFINITE_DAYS_TO_LIVE = -1;
    
    protected String name;
    
    /**
     * this is displayed when grouping news by provider on the multi-category pod
     * news page. doesn't need to be localized, apparently.
     */
    protected String description;
    
    protected String copyright;
    
    protected String copyrightImagePath;
    
	protected int daysToLive;

	public FeedProvider() {
	    daysToLive = INDEFINITE_DAYS_TO_LIVE;
    }
    
	public FeedProvider(String name) {
		this();
		this.name = name.toLowerCase();
	}

	public boolean hasExpiry() {
		return daysToLive != INDEFINITE_DAYS_TO_LIVE;
	}
	
	public int getDaysToLive() {
		return daysToLive;
	}
	
	public String getDescription() {
		return description;
	}
	
	public String getCopyrightImagePath() {
		return copyrightImagePath;
	}
	
	public String getCopyright() {
		return copyright;
	}
	

	public String getName() {
		return name;
	}


	public String toString() {
		return name;
	}



	public void setDaysToLive(int daysToLive) {
    	this.daysToLive = daysToLive;
    }

	public void setDescription(String description) {
    	this.description = description;
    }

	public void setCopyright(String copyright) {
    	this.copyright = copyright;
    }

	public void setCopyrightImagePath(String copyrightImagePath) {
    	this.copyrightImagePath = copyrightImagePath;
    }

	public void setName(String name) {
    	this.name = name;
    }

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof FeedProvider) {
	        FeedProvider feedProvider = (FeedProvider) obj;
	        return feedProvider.name.equals(name);
        }
	    return super.equals(obj);
	}
	
	@Override
	public int hashCode() {
		return name.hashCode();
	}

	public int compareTo(FeedProvider o) {
		return this.name.compareTo(o.name);
	}
}
